package com.zjuee.base.model.common.auth;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.zjuee.base.model.Description;
import com.zjuee.base.valid.Auth;
import com.zjuee.base.valid.Insert;
import com.zjuee.base.valid.Update;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @author wu liang
 * @since 1.0
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@TableName("sys_role")
public class Role extends Description {

    /**
     * 父ID
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @NotNull(message = "parentId can't be empty", groups = {Insert.class, Update.class})
    private Long parentId;

    //角色名
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @NotBlank(message = "name can't be empty", groups = {Insert.class, Auth.class})
//    @Pattern(regexp = "^[a-zA-Z]\\w{2,15}$", message = "invalid name , /^[a-zA-Z]\\w{2,15}$/", groups = {Insert.class})
    @TableField(value = "role_name")
    private String name;

    //标识码
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String roleCode;

    //类型 1系统只读，2自定义
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Byte roleType;

    //组织机构Id
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long orgId;

    //备注信息
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String remark;

    //节点类型
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Byte nodeType;

    @JSONField(serialize = false)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Date gmtCreate;

    @JSONField(serialize = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Date gmtModify;

    @JSONField(serialize = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long createId;

    @JSONField(serialize = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Long modifyId;

    //级别编码
    @JSONField(serialize = false)
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String levelCode;

}
